. /opt/cloudcrv/tg2env/bin/activate

echo "drop database cloudcrv;" | mysql -u root --password=abcdefg; echo "create database cloudcrv;" | mysql -u root --password=abcdefg; paster setup-app /opt/cloudcrv/cloudcrv/CRV/development.ini

rm -frv /opt/cloudcrv/ssl
mkdir -p /opt/cloudcrv/ssl

#put ca cert/keys in place
mv /tmp/ca.crt /opt/cloudcrv/ssl/ca.crt
mv /tmp/ca.prk /opt/cloudcrv/ssl/ca.prk
mv /tmp/ca.puk /opt/cloudcrv/ssl/ca.puk
mv /tmp/ca.pass /opt/cloudcrv/ssl/ca.pass

#put apache turbogears certs/keys in places
mv /tmp/cloudcrvsrv.crt /opt/cloudcrv/ssl/cloudcrvsrv.crt
mv /tmp/cloudcrvsrv.prk /opt/cloudcrv/ssl/cloudcrvsrv.prk
mv /tmp/cloudcrvsrv.puk /opt/cloudcrv/ssl/cloudcrvsrv.puk
mv /tmp/cloudcrvsrv.pass /opt/cloudcrv/ssl/cloudcrvsrv.pass

#put puppetsrv certs/keys in places
mkdir -p /opt/cloudcrv/ssl/ca/signed
mkdir -p /opt/cloudcrv/ssl/private_keys
mv /tmp/puppetsrv.crt /opt/cloudcrv/ssl/ca/signed/puppetsrv.pem
mv /tmp/puppetsrv.prk /opt/cloudcrv/ssl/private_keys/puppetsrv.pem
rm /tmp/puppetsrv.puk
mv /tmp/puppetsrv.pass /opt/cloudcrv/ssl/puppetsrv.pass

sed "s/CLOUDCRVHOME/\/opt\/cloudcrv/g" /opt/cloudcrv/cloudcrv/CRV/apache/getpass>/opt/cloudcrv/ssl/getpass
#change permission
chmod -R 0700 /opt/cloudcrv/ssl/
